home *** CD-ROM | disk | FTP | other *** search
/ Collection of Tools & Utilities / Collection of Tools and Utilities.iso / asmutil / asm_n_z.zip / VGAZOOM2.ASM < prev    next >
Assembly Source File  |  1989-02-22  |  16KB  |  353 lines

  1. ;********************************************************************
  2. ; File VGAZOOM2 - 1280*400 VGA driver procedures
  3. ; Written by Arun Johary & Bo Ericsson,
  4. ; Chips & Technologies Inc.
  5.  
  6. ; This file is not executable as stand-alone. 
  7. ; After assembling, link it with VGAZOOM.OBJ, 
  8. ; then convert to .COM with EXE2BIN.
  9.  
  10. ; Resulting VGAZOOM.COM is a TSR for implementing 1280x480 mode,
  11. ; with zooming to/from 640X480 mode and panning. 
  12. ;********************************************************************
  13.  
  14. LORES equ 0
  15. HIRES equ 1
  16.  
  17. public DRAWCHR
  18. public SETMODE
  19. public HORIZ_SCROLL_4
  20. public VERT_SCROLL
  21. public EndOfProgram
  22.  
  23. code segment para public 'code'
  24.      assume cs:code
  25.  
  26. ;********************************************************************
  27. SETMODE proc near
  28. ; This procedure programs the VGA registers for one of two
  29. ; modes depending on AX
  30. ;  AX  = HIRES -- high resolution 1280*400 monochrome mode
  31. ;  AX  = LORES -- 640*400 monochrome mode
  32.  
  33.         push    cs      ; DS = CS because parameter tables
  34.         pop     ds      ;  are in the current segment
  35.         cld             ; clear for subsequent auto increment
  36.         cmp     ax, HIRES       ; Hires mode ?
  37.         jne     SetMode01       ; if no, test for LORES mode
  38.         lea     bx, HTABLE      ;HIRES table selected
  39.         jmp     SetTheMode      ;program the parameters
  40. SetMode01:                      ;Test for LORES mode
  41.         cmp     ax, LORES       ;LORES mode ?
  42.         jne     SetMode_End1    ;invalid parameter, return to caller
  43.         lea     bx, LTABLE      ;lores table selected
  44.         jmp     SetTheMode      ;program the parameters
  45. SetMode_End1:
  46.         jmp     SetMode_End
  47. SetTheMode:                     ;Sync reset while programming mode
  48.         mov     dx, 3C4H        ;sequencer address
  49.         mov     ax, 0200h       ;sync. reset
  50.         out     dx, ax          ;write the register
  51.                                 ;Set miscellaneous output register
  52.         mov     dx, 3C2H        ;miscllaneous output register address
  53.         mov     al, [bx+9]      ;table value for Misc Output Register.
  54.         out     dx, al          ;write the register
  55.                                 ;Set sequencer registers 01-04
  56.         mov     dx, 3C4H        ;sequencer address
  57.         mov     cx, 4           ;4 registers to write
  58.         mov     ah, 1           ;start with register 1
  59.         mov     si, bx          ;beginning of parameter table
  60.         add     si, 5           ;point to sequencer params in table
  61.         call    W_IndexRegs     ;program the registers
  62.                                 ;Get out of synchronous reset
  63.         mov     dx, 3C4H        ;sequencer address
  64.         mov     ax, 0300h       ;out of reset mode
  65.         out     dx, ax          ;write register
  66.                                 ;Unprotect CRT controller
  67.         mov     dx, 3D4H        ;crtc address
  68.         mov     ax, 011h        ;vertical sync end register
  69.         out     dx, ax          ;set protect bit (D7) to 0
  70.                                 ;Set CRT controller registers 00-18
  71.         mov     cx, 25          ;25 registers to write
  72.         xor     ah, ah          ;start with CRTC register 0
  73.         mov     si, bx          ;beginning of parameter table
  74.         add     si, 10          ;point to CRTC parameters in the table
  75.         call    W_IndexRegs     ;program the registers
  76.                                 ;Set Graphics controller regs 00-08
  77.         mov     dx, 3CEH        ;graphics ctrl address
  78.         mov     cx, 9           ;9 registers to write
  79.         xor     ah, ah          ;start with GC register 0
  80.         mov     si, bx          ;beginning of parameter table
  81.         add     si, 55          ;point to GC parameter in the table
  82.         call    W_IndexRegs     ;program the registers
  83.                                 ;Set Attribute controller regs 00-14
  84.         mov     dx, 3DAH        ;Status register address
  85.         in      al, dx          ;reset attribute flip-flop
  86.         mov     dx, 3c0h        ;attribute ctrl address
  87.         mov     cx, 20          ;20 registers to write
  88.         xor     ah, ah          ;start with register 0
  89.         mov     si, bx          ;beginning of parameter table
  90.         add     si, 35          ;point to Attr. Ctrl params in table
  91.         call    W_Attr_Regs     ;program the registers
  92.         mov     al, 14h         ;write to Attribute color select reg 
  93.         out     dx, al          ;(not stored in parameter table)
  94.         xor     al, al          ;data = 0
  95.         out     dx, al          ;write data
  96.         mov     al, 20h         ;reenable video
  97.         out     dx, al          ;write the index reg to reenable video
  98.                                 ;Set external palette
  99.         mov     dx, 3C6H        ;Palette mask register
  100.         mov     al, 0ffh        ;enable all 8 bits
  101.         out     dx, al          ;write the mask
  102.         mov     dx, 3C8H        ;Palette address register
  103.         lea     si,[bx+64]      ;point to palette parms in table
  104.         xor     ah,ah           ;start at palette reg 0
  105.         mov     cx,4            ;set 4 colors
  106.         call    W_Palette       ;program the palette registers
  107. SetMode_End:    ;end of this procedure
  108.         ret
  109.  
  110. ;********************************************************************
  111. ; These two tables provide parameters for programming VGA hardware
  112. ; in each of two modes.
  113.  
  114. HTABLE label byte  ; parameter table for 1280*400 mono mode
  115.  
  116. db 000h, 000h, 000h, 000h, 000h   ; Dymmy header
  117. db 005h, 00Fh, 000h, 00eh         ; Sequencer offsets 01-04
  118. db 063h                           ; Miscellaneous register
  119.  
  120.                    ; CRT Controller offsets 00-18h
  121. db 05Fh, 04Fh, 050h, 082h, 054h, 080h, 0bFh, 01Fh
  122. db 020h, 000h, 000h, 000h, 000h, 000h, 000h, 000h
  123. db 09ch, 00eh, 08Fh, 014h, 060h, 096h, 0b9h, 0abh, 0FFh
  124.  
  125.                    ; Attribute Controller offsets 00-13h
  126. db 000h, 001h, 002h, 003h, 004h, 005h, 006h, 007h
  127. db 008h, 009h, 00ah, 00bh, 00ch, 00dh, 00eh, 00Fh
  128. db 001h, 000h, 003h, 000h
  129.  
  130.                    ; Graphics Controller offsets 00-08
  131. db 000h, 000h, 000h, 000h, 000h, 020h, 005h, 00Fh, 0FFh
  132.  
  133.                    ; DAC Palette registers 0-3
  134. db 000h, 000h, 000h               ;reg 0: black
  135. db 01ah, 01ah, 01ah               ;reg 1: grey
  136. db 01ah, 01ah, 01ah               ;reg 2: grey
  137. db 02ah, 02ah, 02ah               ;reg 3: white
  138.  
  139. ;********************************************************************
  140. LTABLE label byte  ; parameter table for 640*400 mode
  141.  
  142. db 000h, 000h, 000h, 000h, 000h   ; Dymmy header
  143. db 011h, 00Fh, 000h, 00eh         ; Sequencer offsets 01-04
  144. db 063h                           ; Miscellaneous register
  145.  
  146.                    ; CRT Controller offsets 00-18h
  147. db 05Fh, 050h, 052h, 0e2h, 054h, 0e0h, 0bFh, 01Fh
  148. db 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h
  149. db 09ch, 00eh, 08Fh, 014h, 060h, 096h, 0b9h, 0a3h, 0FFh
  150.  
  151.                    ; Attribute Controller offsets 00-13h
  152. db 000h, 001h, 002h, 003h, 004h, 005h, 006h, 007h
  153. db 008h, 009h, 00ah, 00bh, 00ch, 00dh, 00eh, 00Fh
  154. db 001h, 000h, 001h, 000h
  155.  
  156.                    ; Graphics Controller offsets 0-8
  157. db 000h, 000h, 000h, 000h, 000h, 000h, 005h, 00Fh, 0FFh
  158.  
  159.                    ; DAC Palette registers 0-3
  160. db 000h, 000h, 000h               ;reg 0: black
  161. db 02ah, 02ah, 02ah               ;reg 1: white
  162. db 02ah, 02ah, 02ah               ;reg 2: white
  163. db 02ah, 02ah, 02ah               ;reg 3: white
  164.  
  165. SETMODE endp
  166.  
  167. ;********************************************************************
  168. DRAWCHR proc near
  169. ; this procedure draws a character on the screen in the graphics
  170. ; mode; parameters are expected to be as follows:
  171. ; AL: -- char code
  172. ; BX: -- bit map width
  173. ; DX: -- font height (8 bits only)
  174. ; DS:SI -- Disp Mem pointer
  175. ; ES:DI -- Font pointer
  176.  
  177.         push    cx              ;save CX
  178.         mov     cx,dx           ;get char height in CX
  179.         mul     dl              ;AX gets font offset for character
  180.         add     di,ax           ;ES:DI gets font address for font
  181. LABL0:
  182.         mov     ah,es:[di]      ;read font pattern
  183.         mo